/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ventasautomotrices;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 *
 * @author Chapas BD
 */
public class Receiver {
    /* Ejecuta las solicitudes directamente*/
    
    public boolean  update(String sentence) {
      
    Connection conn = null;
    String url = "jdbc:mysql://localhost:3306/";
    String dbName = "AutoVentas";
    String driver = "com.mysql.jdbc.Driver";
    String userName = "root"; 
    String password = "pass123";
    try {
      Class.forName(driver).newInstance();
      conn = DriverManager.getConnection(url+dbName,userName,password);
      System.out.println("Connected to the database");
      
      Statement st = conn.createStatement();
      
      st.executeUpdate(sentence);
      
               
      
      conn.close();
      System.out.println("Update successful");
      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  
  }
}
